﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/HomeSite.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<TimeTableManagement.Entities.TimeTable>>" %>

<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxTabControl" TagPrefix="dx" %>

<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxRoundPanel" TagPrefix="dx" %>

<%@ Register assembly="DevExpress.Web.v11.1, Version=11.1.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxPanel" tagprefix="dx" %>

<%@ Register assembly="DevExpress.Web.v11.1, Version=11.1.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxClasses" tagprefix="dx" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <dx:ASPxRoundPanel ID="ASPxRoundPanel1" runat="server" Width="100%" 
        CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua" 
        GroupBoxCaptionOffsetY="-28px" 
        SpriteCssFilePath="~/App_Themes/Aqua/{0}/sprite.css">
        <ContentPaddings Padding="14px" />
        <PanelCollection>
<dx:PanelContent runat="server" SupportsDisabledAttribute="True">

<% if (ViewBag.kq == "yes")
   { %>

<h2>Kết quả xếp thời khóa biểu tự động cho học kỳ <%: ViewBag.nameterm.displayword %></h2>
    <dx:ASPxPageControl ID="ASPxPageControl1" runat="server" ActiveTabIndex="0" 
        Width="100%" CssFilePath="~/App_Themes/Aqua/{0}/styles.css" CssPostfix="Aqua" 
        SpriteCssFilePath="~/App_Themes/Aqua/{0}/sprite.css" TabSpacing="3px">
        <TabPages>

            <dx:TabPage Text="Success">
                <ContentCollection>
                    <dx:ContentControl runat="server" SupportsDisabledAttribute="True">
                        <table style="width:100%" id="t1" class="example table-autosort
                             table-autofilter table-autopage:10 
                             table-stripeclass:alternate 
                             table-page-number:t1page table-page-count:t1pages 
                             table-filtered-rowcount:t1filtercount 
                             table-rowcount:t1allcount">
                             <thead>
                            <tr>
                                <th class="table-sortable:alphanumeric">
                                    Code
                                </th>
                                <th class="table-sortable:alphanumeric">
                                    Name
                                </th>
                                <th class="table-sortable:alphanumeric table-filterable">
                                    Lecturer
                                </th>
                                <th class="table-sortable:alphanumeric table-filterable">
                                    Room
                                </th>
                                <th class="table-sortable:alphanumeric table-filterable">
                                    Slot
                                </th>
                            </tr>
                            </thead>
                            <tbody>
                            <% foreach (var item in Model)
                               {
                                   if (item.yesorno)
                                   {%>
                                <tr>
                                    <td id="">
                                        <%: Html.DisplayFor(modelItem => item.code_course)%>
                                    </td>
                                    <td>
                                        <%: Html.DisplayFor(modelItem => item.name_course)%>
                                    </td>
                                    <td id="Td2">
                                        <%: Html.DisplayFor(modelItem => item.name_lecturer)%>
                                    </td>
                                    <td id="Td3">
                                        <%: Html.DisplayFor(modelItem => item.name_room)%>
                                    </td>
                                    <td id="Td4">
                                        <%: Html.DisplayFor(modelItem => item.name_slot)%>
                                    </td>
                                    <td style="display:none" class="jsonmember"
                                        value='{"id_course":<%: item.id_course %>,"code_course":"<%: item.code_course %>","name_course":"<%: item.name_course %>", "id_lecturer":<%: item.id_lecturer %>,"name_lecturer":"<%: item.name_lecturer %>","id_room":<%: item.id_room %>,"name_room":"<%: item.name_room %>","id_slot":<%: item.id_slot %>,"name_slot":"<%: item.name_slot %>","yesorno":true}' >
                                    </td>
                                </tr>
                                
                                <% } %>
                            <% } %>
                            </tbody>
                        <tfoot>
	                        <tr>
		                        <td class="table-page:previous" style="cursor:pointer; text-align:right"><img src="../../Content/iconprevious.png" /></td>
		                        <td style="text-align:center" colspan="3" class="table-page-number:t1page">Page <span id="t1page"></span>&nbsp;of&nbsp;<span id="t1pages"></span></td>
                                <td class="table-page:next" style="cursor:pointer; text-align:left"> <img src="../../Content/iconnext.png" /></td>
	                        </tr>
                        </tfoot>
                        </table>
                    </dx:ContentControl>
                </ContentCollection>
            </dx:TabPage>
            <dx:TabPage Text="UnSuccess">
                <ContentCollection>
                    <dx:ContentControl runat="server" SupportsDisabledAttribute="True">
                        <table style="width:100%" id="Table1" class="example table-autosort
                             table-autofilter table-autopage:7
                             table-stripeclass:alternate 
                             table-page-number:t2page table-page-count:t2pages 
                             table-filtered-rowcount:t1filtercount 
                             table-rowcount:t1allcount">
                             <thead>
                            <tr>
                                <th class="table-sortable:alphanumeric">
                                    Code
                                </th>
                                <th class="table-sortable:alphanumeric">
                                    Name
                                </th>
                                <th class="table-sortable:alphanumeric table-filterable">
                                    Lecturer
                                </th>
                                <th class="table-sortable:alphanumeric table-filterable">
                                    Room
                                </th>
                                <th class="table-sortable:alphanumeric table-filterable">
                                    Slot
                                </th>
                            </tr>
                            </thead>
                            <tbody>
                        <% foreach (var item in Model)
                           {
                               if (!item.yesorno)
                               {%>
                            <tr>
                                <td>
                                    <%: Html.DisplayFor(modelItem => item.code_course)%>
                                </td>
                                <td>
                                   <%-- <%: TimeTableManagement.Models.Functions.Truncate(item.name_course,10)%>--%>
                                   <%: Html.DisplayFor(modelItem => item.name_course)%>
                                </td>
                                <td>
                                    <%: Html.DisplayFor(modelItem => item.name_lecturer)%>
                                </td>
                                <td>
                                    <%: Html.DisplayFor(modelItem => item.name_room)%>
                                </td>
                                <td>
                                    <%: Html.DisplayFor(modelItem => item.name_slot)%>
                                </td>
                            </tr>
                            <% } %>
                        <% } %>
                        </tbody>
                        <tfoot>
	                        <tr>
		                        <td class="table-page:previous" style="cursor:pointer; text-align:right"><img src="../../Content/iconprevious.png" /></td>
		                        <td style="text-align:center" colspan="3" class="table-page-number:t2page">Page <span id="t2page"></span>&nbsp;of&nbsp;<span id="t2pages"></span></td>
                                <td class="table-page:next" style="cursor:pointer; text-align:left"> <img src="../../Content/iconnext.png" /></td>
	                        </tr>
                        </tfoot>
                        </table>
                    </dx:ContentControl>
                </ContentCollection>
            </dx:TabPage>
        </TabPages>
        <LoadingPanelImage Url="~/App_Themes/Aqua/Web/Loading.gif">
        </LoadingPanelImage>
        <Paddings Padding="2px" PaddingLeft="5px" PaddingRight="5px" />
        <ContentStyle>
            <Border BorderColor="#AECAF0" BorderStyle="Solid" BorderWidth="1px" />
        </ContentStyle>
    </dx:ASPxPageControl>
    <h2>Xác nhận</h2>
    <p>Nếu đồng ý với kết quả trên, bạn hãy click Xác Nhận để lưu thời khóa biểu này. Lưu ý: Chỉ lưu những môn được xếp thành công.</p>
    <% using (Html.BeginForm("Create", "TimeTable", FormMethod.Post))
       { %>
        <input id="id_term" name="term" type="hidden" value="<%: ViewBag.nameterm.id %>" />
        <input id="id_course" name="id_course" type="hidden" value="" />
        <input id="id_lecturer" name="id_lecturer" type="hidden" value="" />
        <input id="id_room" name="id_room" type="hidden" value="" />
        <input id="id_slot" name="id_slot" type="hidden" value="" />
        <input id="status" name="status" type="hidden" value="true" />
        <input id="count" name="count" type="hidden" value=0 />

        <input id="timetablejson" name="timetablejson" type="hidden" value="" />
        <input id="Submit1" type="submit" value="Xác Nhận" onclick = "return updatejsonsuccessfull()"/>
    <% } %>

<% }
   else
   {%>
<h2>Dữ liệu không đủ để tạo thời khóa biểu tự động. Vui long thêm giảng viên, phòng và slot.</h2>
<% } %>
</dx:PanelContent>
</PanelCollection>
    </dx:ASPxRoundPanel>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="HeadContent" runat="server">
<script type="text/javascript">
    function updatejsonsuccessfull() {
        json = ""
        items = document.getElementsByClassName('jsonmember');
        for (i = 0; i < items.length; i++) {
            item = items.item(i);
            value = item.getAttribute('value');
            json = json + "," + value;
        }
        json =json.substr(1);
        json = "[" + json + "]";
        document.getElementById('timetablejson').value = json;
        return true;
    }
</script>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="leftmenu" runat="server">
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="menuright" runat="server">
</asp:Content>

<asp:Content ID="Content5" ContentPlaceHolderID="Footer" runat="server">
</asp:Content>
